<?php 

/**
 * @author iexn
 * @version 3.0.0
 * @time 2019-02-13 16:43:01
 * @link https://gitee.com/tianjin_onfinger/w7_scaffold
 */
defined('APP_DIR') or exit('未设置APP_DIR常量');
defined('APP_PATH') and exit('不能设置APP_PATH常量。您可能是想设置APP_DIR');

define('WSYS_VERSION', '3.0.0');
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
defined('EXT') or define('EXT', '.php');
defined('APP_DEBUG') or define('APP_DEBUG', false);
defined('UNI_BRIDLE') or define('UNI_BRIDLE', true);
defined('APP_ARCHITECTURE') or define('APP_ARCHITECTURE', 'TP3');
define('WSYS_THEME', 'default');
define('ADDON_PATH', APP_DIR . DS);
define('APP_PATH', ADDON_PATH . 'application' . DS);
define('CONF_PATH', APP_PATH);
define('CONF_EXT', EXT);
define('APP_NAME', basename(dirname(APP_PATH)));
defined('WSYS_TEMPLATE') or define('WSYS_TEMPLATE', 'W7');
defined('WSYS_SYSTEM_PREFIX') or define('WSYS_SYSTEM_PREFIX', 'wsys_');
defined('WSYS_PREFIX') or define('WSYS_PREFIX', WSYS_SYSTEM_PREFIX . APP_NAME . '_');

define('LIB_PATH', WSYS_PATH . 'library' . DS);
define('WSYS_COMMON_PATH', WSYS_PATH . 'common' . DS);
define('WSYS_VENDOR_PATH', WSYS_PATH . 'vendor' . DS);
define('VENDOR_PATH', LIB_PATH . 'vendor' . DS);

define('IS_CLI', PHP_SAPI == 'cli' ? true : false);
define('IS_WIN', strpos(PHP_OS, 'WIN') !== false);

// app端访问静态资源路径
if(isset($_SERVER['HTTP_HOST'])) {
    $resource_path = htmlspecialchars((
        (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) ||
        (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ||
        (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') ||
        (isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') ? 'https://' : 'http://'
    ) . $_SERVER['HTTP_HOST']).'/addons/'. MNAME .'/resource';
} else {
    $resource_path = ADDON_PATH . 'resource';
}
define('WEB_RESOURCE', $resource_path);

// 系统静态资源路径，不同网站和app端对应不同的资源路径
define('SYSTEM_RESOURCE', './resource');


// 开始搭建系统环境
include LIB_PATH . 'wsys' . DS . 'Loader.php';
\wsys\Loader::register();
\wsys\Config::set(include WSYS_PATH . 'convention' . EXT);
